package com.hdaccp.mybatis.util;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import java.io.IOException;
import java.io.InputStream;

public class BaseDao {
    public SqlSession getSession(){
        SqlSession session = null ;
        try {
            InputStream inputStream = Resources.getResourceAsStream("mybatis-config.xml") ;
            SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
            SqlSessionFactory sessionFactory = builder.build(inputStream) ;
            session = sessionFactory.openSession() ;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return session ;
    }
}
